<?php
namespace app\admin\controller;
use think\Controller;
use think\Request;
/**
 * Created by PhpStorm.
 * User: 空房间
 * Date: 2018/2/25
 * Time: 10:22
 */
class Questionnaire extends Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->db=new \app\admin\model\Questionnaire;
    }

    /**
     * 调查问卷展示
     */
    public function questionnaire_view()
    {
        $condition = array(
            'subbranch_id'  =>  2,//测试数据
        );
        $info = $this->db->getSetInfo($condition);
        $this->assign('info',$info);
        return view();
    }

    /**
     * 添加
     */
    public function questionnaire_add()
    {
        if(Request::instance()->isPost()){
            $data = input('post.');
            if(!empty($data)){
                $inser_info = array(
                    'uid'          =>  '23',//假数据
                    'subbranch_id'=> '2',//假数据
                    'patient_id'   =>   3,//假数据
                    'patient_answer'=>json_encode($data),
                    'create_time'=>time(),
                    'update_time'=>time()
                );
                $result = $this->db->questionnaire_add($inser_info);
                return  $result ? $this->success('成功') : $this->error('失败');
            }
        }
    }
}